//==============================================================================
//
//         DSimpleFont - a simple, bitmap font in the ofc-library
//
//               Copyright (C) 2007  Dick van Oudheusden
//  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
// 
//  $Date: 2007-07-22 06:21:27 $ $Revision: 1.3 $
//
//==============================================================================

#include "ofc/DSimpleFont.h"

#include "SDL.h"


#define DSF_SIZE  (8)


#if _INTERFACE_

#include "ofc/config.h"

#include "ofc/DFont.h"


//
// The DSimpleFont class implements a simple 8x8 bitmap font. It is used as a start
// font. It only implements the characters space till ~, all others are translated
// to a '?'.
// 

@interface DSimpleFont : Object <DFont>
{
}

#endif


#if _PRIVATE_


static char _familyName[] = "bitmap";
static char _styleName[]  = "unknown";


  // The font bitmap is copied and modified from SDL_gfx library LGPL (c) A. Schiffler

static unsigned char _bitmap[] = 
{
    /*
     * 32 0x20 ' ' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 33 0x21 '!' 
     */
    0x18, /* 00011000 */
    0x3c, /* 00111100 */
    0x3c, /* 00111100 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */

    /*
     * 34 0x22 '"' 
     */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x24, /* 00100100 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 35 0x23 '#' 
     */
    0x6c, /* 01101100 */
    0x6c, /* 01101100 */
    0xfe, /* 11111110 */
    0x6c, /* 01101100 */
    0xfe, /* 11111110 */
    0x6c, /* 01101100 */
    0x6c, /* 01101100 */
    0x00, /* 00000000 */

    /*
     * 36 0x24 '$' 
     */
    0x18, /* 00011000 */
    0x3e, /* 00111110 */
    0x60, /* 01100000 */
    0x3c, /* 00111100 */
    0x06, /* 00000110 */
    0x7c, /* 01111100 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */

    /*
     * 37 0x25 '%' 
     */
    0x00, /* 00000000 */
    0xc6, /* 11000110 */
    0xcc, /* 11001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x66, /* 01100110 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 38 0x26 '&' 
     */
    0x38, /* 00111000 */
    0x6c, /* 01101100 */
    0x38, /* 00111000 */
    0x76, /* 01110110 */
    0xdc, /* 11011100 */
    0xcc, /* 11001100 */
    0x76, /* 01110110 */
    0x00, /* 00000000 */

    /*
     * 39 0x27 ''' 
     */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 40 0x28 '(' 
     */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x00, /* 00000000 */

    /*
     * 41 0x29 ')' 
     */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x00, /* 00000000 */

    /*
     * 42 0x2a '*' 
     */
    0x00, /* 00000000 */
    0x66, /* 01100110 */
    0x3c, /* 00111100 */
    0xff, /* 11111111 */
    0x3c, /* 00111100 */
    0x66, /* 01100110 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 43 0x2b '+' 
     */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x7e, /* 01111110 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 44 0x2c ',' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */

    /*
     * 45 0x2d '-' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7e, /* 01111110 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 46 0x2e '.' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */

    /*
     * 47 0x2f '/' 
     */
    0x06, /* 00000110 */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x60, /* 01100000 */
    0xc0, /* 11000000 */
    0x80, /* 10000000 */
    0x00, /* 00000000 */

    /*
     * 48 0x30 '0' 
     */
    0x38, /* 00111000 */
    0x6c, /* 01101100 */
    0xc6, /* 11000110 */
    0xd6, /* 11010110 */
    0xc6, /* 11000110 */
    0x6c, /* 01101100 */
    0x38, /* 00111000 */
    0x00, /* 00000000 */

    /*
     * 49 0x31 '1' 
     */
    0x18, /* 00011000 */
    0x38, /* 00111000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x7e, /* 01111110 */
    0x00, /* 00000000 */

    /*
     * 50 0x32 '2' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0x06, /* 00000110 */
    0x1c, /* 00011100 */
    0x30, /* 00110000 */
    0x66, /* 01100110 */
    0xfe, /* 11111110 */
    0x00, /* 00000000 */

    /*
     * 51 0x33 '3' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0x06, /* 00000110 */
    0x3c, /* 00111100 */
    0x06, /* 00000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 52 0x34 '4' 
     */
    0x1c, /* 00011100 */
    0x3c, /* 00111100 */
    0x6c, /* 01101100 */
    0xcc, /* 11001100 */
    0xfe, /* 11111110 */
    0x0c, /* 00001100 */
    0x1e, /* 00011110 */
    0x00, /* 00000000 */

    /*
     * 53 0x35 '5' 
     */
    0xfe, /* 11111110 */
    0xc0, /* 11000000 */
    0xc0, /* 11000000 */
    0xfc, /* 11111100 */
    0x06, /* 00000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 54 0x36 '6' 
     */
    0x38, /* 00111000 */
    0x60, /* 01100000 */
    0xc0, /* 11000000 */
    0xfc, /* 11111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 55 0x37 '7' 
     */
    0xfe, /* 11111110 */
    0xc6, /* 11000110 */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x00, /* 00000000 */

    /*
     * 56 0x38 '8' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 57 0x39 '9' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7e, /* 01111110 */
    0x06, /* 00000110 */
    0x0c, /* 00001100 */
    0x78, /* 01111000 */
    0x00, /* 00000000 */

    /*
     * 58 0x3a ':' 
     */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */

    /*
     * 59 0x3b ';' 
     */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */

    /*
     * 60 0x3c '<' 
     */
    0x06, /* 00000110 */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x06, /* 00000110 */
    0x00, /* 00000000 */

    /*
     * 61 0x3d '=' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7e, /* 01111110 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7e, /* 01111110 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 62 0x3e '>' 
     */
    0x60, /* 01100000 */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x30, /* 00110000 */
    0x60, /* 01100000 */
    0x00, /* 00000000 */

    /*
     * 63 0x3f '?' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0x0c, /* 00001100 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */

    /*
     * 64 0x40 '@' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xde, /* 11011110 */
    0xde, /* 11011110 */
    0xde, /* 11011110 */
    0xc0, /* 11000000 */
    0x78, /* 01111000 */
    0x00, /* 00000000 */

    /*
     * 65 0x41 'A' 
     */
    0x38, /* 00111000 */
    0x6c, /* 01101100 */
    0xc6, /* 11000110 */
    0xfe, /* 11111110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 66 0x42 'B' 
     */
    0xfc, /* 11111100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x7c, /* 01111100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0xfc, /* 11111100 */
    0x00, /* 00000000 */

    /*
     * 67 0x43 'C' 
     */
    0x3c, /* 00111100 */
    0x66, /* 01100110 */
    0xc0, /* 11000000 */
    0xc0, /* 11000000 */
    0xc0, /* 11000000 */
    0x66, /* 01100110 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 68 0x44 'D' 
     */
    0xf8, /* 11111000 */
    0x6c, /* 01101100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x6c, /* 01101100 */
    0xf8, /* 11111000 */
    0x00, /* 00000000 */

    /*
     * 69 0x45 'E' 
     */
    0xfe, /* 11111110 */
    0x62, /* 01100010 */
    0x68, /* 01101000 */
    0x78, /* 01111000 */
    0x68, /* 01101000 */
    0x62, /* 01100010 */
    0xfe, /* 11111110 */
    0x00, /* 00000000 */

    /*
     * 70 0x46 'F' 
     */
    0xfe, /* 11111110 */
    0x62, /* 01100010 */
    0x68, /* 01101000 */
    0x78, /* 01111000 */
    0x68, /* 01101000 */
    0x60, /* 01100000 */
    0xf0, /* 11110000 */
    0x00, /* 00000000 */

    /*
     * 71 0x47 'G' 
     */
    0x3c, /* 00111100 */
    0x66, /* 01100110 */
    0xc0, /* 11000000 */
    0xc0, /* 11000000 */
    0xce, /* 11001110 */
    0x66, /* 01100110 */
    0x3a, /* 00111010 */
    0x00, /* 00000000 */

    /*
     * 72 0x48 'H' 
     */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xfe, /* 11111110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 73 0x49 'I' 
     */
    0x3c, /* 00111100 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 74 0x4a 'J' 
     */
    0x1e, /* 00011110 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0x78, /* 01111000 */
    0x00, /* 00000000 */

    /*
     * 75 0x4b 'K' 
     */
    0xe6, /* 11100110 */
    0x66, /* 01100110 */
    0x6c, /* 01101100 */
    0x78, /* 01111000 */
    0x6c, /* 01101100 */
    0x66, /* 01100110 */
    0xe6, /* 11100110 */
    0x00, /* 00000000 */

    /*
     * 76 0x4c 'L' 
     */
    0xf0, /* 11110000 */
    0x60, /* 01100000 */
    0x60, /* 01100000 */
    0x60, /* 01100000 */
    0x62, /* 01100010 */
    0x66, /* 01100110 */
    0xfe, /* 11111110 */
    0x00, /* 00000000 */

    /*
     * 77 0x4d 'M' 
     */
    0xc6, /* 11000110 */
    0xee, /* 11101110 */
    0xfe, /* 11111110 */
    0xfe, /* 11111110 */
    0xd6, /* 11010110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 78 0x4e 'N' 
     */
    0xc6, /* 11000110 */
    0xe6, /* 11100110 */
    0xf6, /* 11110110 */
    0xde, /* 11011110 */
    0xce, /* 11001110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 79 0x4f 'O' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 80 0x50 'P' 
     */
    0xfc, /* 11111100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x7c, /* 01111100 */
    0x60, /* 01100000 */
    0x60, /* 01100000 */
    0xf0, /* 11110000 */
    0x00, /* 00000000 */

    /*
     * 81 0x51 'Q' 
     */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xce, /* 11001110 */
    0x7c, /* 01111100 */
    0x0e, /* 00001110 */

    /*
     * 82 0x52 'R' 
     */
    0xfc, /* 11111100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x7c, /* 01111100 */
    0x6c, /* 01101100 */
    0x66, /* 01100110 */
    0xe6, /* 11100110 */
    0x00, /* 00000000 */

    /*
     * 83 0x53 'S' 
     */
    0x3c, /* 00111100 */
    0x66, /* 01100110 */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x66, /* 01100110 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 84 0x54 'T' 
     */
    0x7e, /* 01111110 */
    0x7e, /* 01111110 */
    0x5a, /* 01011010 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 85 0x55 'U' 
     */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 86 0x56 'V' 
     */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x6c, /* 01101100 */
    0x38, /* 00111000 */
    0x00, /* 00000000 */

    /*
     * 87 0x57 'W' 
     */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xd6, /* 11010110 */
    0xd6, /* 11010110 */
    0xfe, /* 11111110 */
    0x6c, /* 01101100 */
    0x00, /* 00000000 */

    /*
     * 88 0x58 'X' 
     */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x6c, /* 01101100 */
    0x38, /* 00111000 */
    0x6c, /* 01101100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 89 0x59 'Y' 
     */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x3c, /* 00111100 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 90 0x5a 'Z' 
     */
    0xfe, /* 11111110 */
    0xc6, /* 11000110 */
    0x8c, /* 10001100 */
    0x18, /* 00011000 */
    0x32, /* 00110010 */
    0x66, /* 01100110 */
    0xfe, /* 11111110 */
    0x00, /* 00000000 */

    /*
     * 91 0x5b '[' 
     */
    0x3c, /* 00111100 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 92 0x5c '\' 
     */
    0xc0, /* 11000000 */
    0x60, /* 01100000 */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x06, /* 00000110 */
    0x02, /* 00000010 */
    0x00, /* 00000000 */

    /*
     * 93 0x5d ']' 
     */
    0x3c, /* 00111100 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x0c, /* 00001100 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 94 0x5e '^' 
     */
    0x10, /* 00010000 */
    0x38, /* 00111000 */
    0x6c, /* 01101100 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 95 0x5f '_' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xff, /* 11111111 */

    /*
     * 96 0x60 '`' 
     */
    0x30, /* 00110000 */
    0x18, /* 00011000 */
    0x0c, /* 00001100 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */

    /*
     * 97 0x61 'a' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x78, /* 01111000 */
    0x0c, /* 00001100 */
    0x7c, /* 01111100 */
    0xcc, /* 11001100 */
    0x76, /* 01110110 */
    0x00, /* 00000000 */

    /*
     * 98 0x62 'b' 
     */
    0xe0, /* 11100000 */
    0x60, /* 01100000 */
    0x7c, /* 01111100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0xdc, /* 11011100 */
    0x00, /* 00000000 */

    /*
     * 99 0x63 'c' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc0, /* 11000000 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 100 0x64 'd' 
     */
    0x1c, /* 00011100 */
    0x0c, /* 00001100 */
    0x7c, /* 01111100 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0x76, /* 01110110 */
    0x00, /* 00000000 */

    /*
     * 101 0x65 'e' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xfe, /* 11111110 */
    0xc0, /* 11000000 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 102 0x66 'f' 
     */
    0x3c, /* 00111100 */
    0x66, /* 01100110 */
    0x60, /* 01100000 */
    0xf8, /* 11111000 */
    0x60, /* 01100000 */
    0x60, /* 01100000 */
    0xf0, /* 11110000 */
    0x00, /* 00000000 */

    /*
     * 103 0x67 'g' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x76, /* 01110110 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0x7c, /* 01111100 */
    0x0c, /* 00001100 */
    0xf8, /* 11111000 */

    /*
     * 104 0x68 'h' 
     */
    0xe0, /* 11100000 */
    0x60, /* 01100000 */
    0x6c, /* 01101100 */
    0x76, /* 01110110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0xe6, /* 11100110 */
    0x00, /* 00000000 */

    /*
     * 105 0x69 'i' 
     */
    0x18, /* 00011000 */
    0x00, /* 00000000 */
    0x38, /* 00111000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 106 0x6a 'j' 
     */
    0x06, /* 00000110 */
    0x00, /* 00000000 */
    0x06, /* 00000110 */
    0x06, /* 00000110 */
    0x06, /* 00000110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x3c, /* 00111100 */

    /*
     * 107 0x6b 'k' 
     */
    0xe0, /* 11100000 */
    0x60, /* 01100000 */
    0x66, /* 01100110 */
    0x6c, /* 01101100 */
    0x78, /* 01111000 */
    0x6c, /* 01101100 */
    0xe6, /* 11100110 */
    0x00, /* 00000000 */

    /*
     * 108 0x6c 'l' 
     */
    0x38, /* 00111000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x3c, /* 00111100 */
    0x00, /* 00000000 */

    /*
     * 109 0x6d 'm' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xec, /* 11101100 */
    0xfe, /* 11111110 */
    0xd6, /* 11010110 */
    0xd6, /* 11010110 */
    0xd6, /* 11010110 */
    0x00, /* 00000000 */

    /*
     * 110 0x6e 'n' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xdc, /* 11011100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x00, /* 00000000 */

    /*
     * 111 0x6f 'o' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7c, /* 01111100 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7c, /* 01111100 */
    0x00, /* 00000000 */

    /*
     * 112 0x70 'p' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xdc, /* 11011100 */
    0x66, /* 01100110 */
    0x66, /* 01100110 */
    0x7c, /* 01111100 */
    0x60, /* 01100000 */
    0xf0, /* 11110000 */

    /*
     * 113 0x71 'q' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x76, /* 01110110 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0x7c, /* 01111100 */
    0x0c, /* 00001100 */
    0x1e, /* 00011110 */

    /*
     * 114 0x72 'r' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xdc, /* 11011100 */
    0x76, /* 01110110 */
    0x60, /* 01100000 */
    0x60, /* 01100000 */
    0xf0, /* 11110000 */
    0x00, /* 00000000 */

    /*
     * 115 0x73 's' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7e, /* 01111110 */
    0xc0, /* 11000000 */
    0x7c, /* 01111100 */
    0x06, /* 00000110 */
    0xfc, /* 11111100 */
    0x00, /* 00000000 */

    /*
     * 116 0x74 't' 
     */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0xfc, /* 11111100 */
    0x30, /* 00110000 */
    0x30, /* 00110000 */
    0x36, /* 00110110 */
    0x1c, /* 00011100 */
    0x00, /* 00000000 */

    /*
     * 117 0x75 'u' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0xcc, /* 11001100 */
    0x76, /* 01110110 */
    0x00, /* 00000000 */

    /*
     * 118 0x76 'v' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x6c, /* 01101100 */
    0x38, /* 00111000 */
    0x00, /* 00000000 */

    /*
     * 119 0x77 'w' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xc6, /* 11000110 */
    0xd6, /* 11010110 */
    0xd6, /* 11010110 */
    0xfe, /* 11111110 */
    0x6c, /* 01101100 */
    0x00, /* 00000000 */

    /*
     * 120 0x78 'x' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xc6, /* 11000110 */
    0x6c, /* 01101100 */
    0x38, /* 00111000 */
    0x6c, /* 01101100 */
    0xc6, /* 11000110 */
    0x00, /* 00000000 */

    /*
     * 121 0x79 'y' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0xc6, /* 11000110 */
    0x7e, /* 01111110 */
    0x06, /* 00000110 */
    0xfc, /* 11111100 */

    /*
     * 122 0x7a 'z' 
     */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x7e, /* 01111110 */
    0x4c, /* 01001100 */
    0x18, /* 00011000 */
    0x32, /* 00110010 */
    0x7e, /* 01111110 */
    0x00, /* 00000000 */

    /*
     * 123 0x7b '{' 
     */
    0x0e, /* 00001110 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x70, /* 01110000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x0e, /* 00001110 */
    0x00, /* 00000000 */

    /*
     * 124 0x7c '|' 
     */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x00, /* 00000000 */

    /*
     * 125 0x7d '}' 
     */
    0x70, /* 01110000 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x0e, /* 00001110 */
    0x18, /* 00011000 */
    0x18, /* 00011000 */
    0x70, /* 01110000 */
    0x00, /* 00000000 */

    /*
     * 126 0x7e '~' 
     */
    0x76, /* 01110110 */
    0xdc, /* 11011100 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00, /* 00000000 */
    0x00  /* 00000000 */
};

#endif


@implementation DSimpleFont

//
// Initialise a simple bitmap font
//
// @return the object
//
- (DSimpleFont *) init
{
  [super init];
  
  return self;
}


//// Copy related methods

//
// Do a shallow copy of a simple bitmap font
//
// @return the object
//
- shallowCopy
{
  DSimpleFont *copy = [super shallowCopy];
  
  return copy;
}


//// Deconstructor

//
// Free the font
// 
// @return the object
// 
- free
{
  return [super free];
}



//// Font members

//
// Get the family name of the font
//
// @return the family name (or NULL)
//
- (const char *) familyName
{
  return _familyName;
}


//
// Get the style name of the font
//
// @return the style name (or NULL)
//
- (const char *) styleName
{
  return _styleName;
}


//
// Get the number of characters in font
//
// @return the number of characters in the font (or -1)
//
- (int) glyphsInFont
{
  return sizeof(_bitmap) / (DSF_SIZE * sizeof(_bitmap[0]));
}



//// Font methods

//
// Set the font size based on the width and height of one character
// 
// @param width         the requested width
// @param height        the requested height
//
// @return success
//
- (BOOL) size :(unsigned) width :(unsigned) height
{
  return NO;  // not resizable
}

//
// Set the font size based on a string and requested a size
// 
// @param cstr          the string
// @param width         the requested width
// @param height        the requested height
//
// @return success
//
- (BOOL) size :(const char *) cstr :(unsigned) width :(unsigned) height
{
  return NO;  // not resizable
}

//
// Get the size of a string for the current font size
// 
// @param cstr          the string
// @param width         the width of the string
// @param height        the height of the string
//
// @return success
//
- (BOOL) stringSize :(const char *) cstr :(unsigned *) width :(unsigned *) height
{
  *height = DSF_SIZE;
  
  if ((cstr == NULL) || (*cstr == EOS))
  {
    *width = 0;
  }
  else
  {
    *width = strlen(cstr) * DSF_SIZE;
  }
  
  return YES;
}

//
// Get the size of a character for the current font and size
// 
// @param ch            the character
// @param width         the width of the string
// @param height        the height of the string
//
// @return success
//
- (BOOL) charSize :(char) ch :(unsigned *) width :(unsigned *) height
{
  *height = *width = DSF_SIZE;
  
  return YES;
}


//
// Get the glyph info for blitting a character for the current font and size
// 
// @param ch            the character
// @param glyph         the character bitmap and blit info
//
// @return success
//
- (BOOL) glyph :(char) ch :(DFT_Glyph *) glyph
{
  BOOL ok = NO;
  
  if (glyph == NULL)
  {
    WARNING(DW_INVALID_ARG, "glyph");
  }
  else
  {
    if ((ch < 32) || (ch > 126))
    {
      ch = '?';
    }
    
    glyph->offsetX      = 0;
    glyph->offsetY      = 0;
    glyph->advanceX     = DSF_SIZE;
    glyph->advanceY     = DSF_SIZE;

    glyph->ascender     = 0;
    glyph->descender    = 0;
    glyph->height       = DSF_SIZE+2;

    glyph->bitmap       = _bitmap + (ch - 32) * DSF_SIZE * sizeof(unsigned char);
    glyph->bitmapHeight = DSF_SIZE;
    glyph->bitmapWidth  = DSF_SIZE;
    glyph->bitmapPitch  = 1;

    ok = YES;
  }
  
  return ok;
}

@end

/*===========================================================================*/
